﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GingerBeard.Utilities;
using System.Diagnostics;
using System.IO;

namespace GingerBeard.IDL
{
	public enum VariableType
	{
		Data,
		Link,
		Array
	}

	public abstract class IDLNode : Node
	{
		public const int DefaultAlignment = 1;

		String name;
		public System.String Name
		{
			get { return name; }
			set { name = value; }
		}
		int alignment;
		public int Alignment
		{
			get { return alignment; }
			set { alignment = value; }
		}
		String obsolete;
		public String Obsolete
		{
			get { return obsolete; }
			set { obsolete = value; }
		}
        public abstract bool GeneratePre_CSharp(CompileSettings settings);
        public abstract void GeneratePost_CSharp(CompileSettings settings);
		public abstract bool GeneratePre_CPlusPlus(CompileSettings settings);
		public abstract void GeneratePost_CPlusPlus(CompileSettings settings);

		public IDLNode FindNamedNode(String name, bool recurse)
		{
			if (Name == name)
				return this;

			if (recurse)
			{
				IDLNode rtn = null;
				foreach (IDLNode child in Nodes)
				{
					rtn = child.FindNamedNode(name, recurse);
					if (rtn != null)
						return rtn;
				}
			}

			return null;
		}

		#region INode Members

		public void AddNode(object o)
		{
			Debug.Assert(o is IDLNode);
			Nodes.Add(o as IDLNode);
		}

		#endregion
	}

    public partial class IDLVariable : IDLNode
	{
		String type;
		public System.String Type
		{
			get { return type; }
			set { type = value; }
		}

	}

    public partial class IDLObject : IDLNode
	{
	}

    public partial class IDLEnum : IDLNode
	{
		String values;
		public System.String Values
		{
			get { return values; }
			set { values = value; }
		}
	}

	public partial class IDLNamespace : IDLNode
	{
	}

    public partial class IDLIfLanguage : IDLNode
	{
	}

    public partial class IDLTypes : IDLNode
	{
	}

    public partial class IDLType : IDLNode
	{
		String actualType;
		public System.String ActualType
		{
			get { return actualType; }
			set { actualType = value; }
		}
	}

	public partial class IDLContainer : IDLNode
	{
		String type;
		public System.String Type
		{
			get { return type; }
			set { type = value; }
		}
	}

	public partial class IDL : IDLNode
	{
		String sourceFilename = "<unset>";
		public System.String SourceFilename
		{
			get { return sourceFilename; }
			set { sourceFilename = value; }
		}
	}
}
